package com.gxuwz.zlc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gxuwz.zlc.entity.Apply;
import com.gxuwz.zlc.mapper.ApplyMapper;
import com.gxuwz.zlc.service.ApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ApplyServiceImpl implements ApplyService {

    @Autowired
    private ApplyMapper applyMapper;

    @Override
    public List<Apply> findApply() {
        return applyMapper.selectList(null);
    }

    @Override
    public Apply findApplyById(Integer applyId) {
        return applyMapper.selectById(applyId);
    }

    @Override
    public void addApply(Apply apply) {
        applyMapper.insert(apply);
    }

    @Override
    public void updateApply(Apply apply) {
        applyMapper.updateById(apply);
    }

    @Override
    public void deleteApply(Integer applyId) {
        applyMapper.deleteById(applyId);
    }

    @Override
    public void updateApplyByStuId(Apply apply, String stuId) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("stu_id",stuId);
        applyMapper.update(apply,wrapper);
    }

    @Override
    public Apply findApplyByStuId(String stuId) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("stu_id",stuId);
        return applyMapper.selectOne(wrapper);
    }


}
